package org.sft.cxf;

import javax.annotation.Resource;
import javax.xml.ws.Endpoint;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration

public class CXFConfig {
	@Resource
	private FirstService firstService;
	@Bean
	public ServletRegistrationBean CXFServlet() {
		return new ServletRegistrationBean(new CXFServlet(), "/soap/*");
	}
	@Bean(name = Bus.DEFAULT_BUS_ID)
	public SpringBus springBus() {
		return new SpringBus();
	}
    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), firstService);
        endpoint.publish("/first");
        return endpoint;
    }
	
}
